package com.itrip.service.impl;

import com.itrip.dao.ex.HotelMapper;
import com.itrip.document.Hotel;
import com.itrip.dto.HotelDTO;
import com.itrip.dto.RoomDTO;
import com.itrip.repository.HotelRepository;
import com.itrip.service.HotelService;
import com.itrip.vo.HotelSelectVo;
import org.apache.solr.client.solrj.SolrServerException;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

@Service
public class HotelServiceImpl implements HotelService {
    @Resource
    private HotelMapper hotelMapper;

    @Resource
    private HotelRepository hotelRepository;

    @Cacheable(value = "hotel",key = "'selectHotelRoom:'+#hotelId")
    @Override
    public List<RoomDTO> selectHotelRoom(int hotelId) {
        return hotelMapper.selectHotelRoom(hotelId);
    }

    @Override
    public List<HotelDTO> getAllHotel(Integer start, Integer pageSize) {
        return hotelMapper.getAllHotel( start,pageSize);
    }

    @Override
    public List<Hotel> selectHotelBySolr(HotelSelectVo hotelSelectVo) throws IOException, SolrServerException {
        return hotelRepository.selectHotelBySolr(hotelSelectVo);
    }

    @Override
    public int getHotelNum() {
        return hotelMapper.getHotelNum();
    }

}
